/*
 * FtpCodeCase.cpp
 *
 *  Created on: 2012-12-25
 *      Author: yangentao@gmail.com
 */

#include "test.h"
#include "../src/ftp/Packet.h"

using namespace yet;
using namespace ftp;

TEST(FtpCode, ABOR) {
	int n = 0;
	n = testFtpCode(FTP_ABOR, 100);
	EXPECT_EQ(n, FTP_ERROR);
	n = testFtpCode(FTP_ABOR, 200);
	EXPECT_EQ(n, FTP_OK);
	n = testFtpCode(FTP_ABOR, 300);
	EXPECT_EQ(n, FTP_ERROR);
	n = testFtpCode(FTP_ABOR, 400);
	EXPECT_EQ(n, FTP_FAILED);
	n = testFtpCode(FTP_ABOR, 500);
	EXPECT_EQ(n, FTP_FAILED);
}
TEST(FtpCode, APPE) {
	int n = 0;
	n = testFtpCode(FTP_APPE, 100);
	EXPECT_EQ(n, FTP_WAIT);
	n = testFtpCode(FTP_APPE, 200);
	EXPECT_EQ(n, FTP_OK);
	n = testFtpCode(FTP_APPE, 300);
	EXPECT_EQ(n, FTP_ERROR);
	n = testFtpCode(FTP_APPE, 400);
	EXPECT_EQ(n, FTP_FAILED);
	n = testFtpCode(FTP_APPE, 500);
	EXPECT_EQ(n, FTP_FAILED);
}
TEST(FtpCode, RNFR_REST) {
	int n = 0;
	n = testFtpCode(FTP_RNFR, 100);
	EXPECT_EQ(n, FTP_ERROR);
	n = testFtpCode(FTP_RNFR, 200);
	EXPECT_EQ(n, FTP_ERROR);
	n = testFtpCode(FTP_RNFR, 300);
	EXPECT_EQ(n, FTP_NEXT);
	n = testFtpCode(FTP_RNFR, 400);
	EXPECT_EQ(n, FTP_FAILED);
	n = testFtpCode(FTP_RNFR, 500);
	EXPECT_EQ(n, FTP_FAILED);
}
TEST(FtpCode, RNTO) {
	int n = 0;
	n = testFtpCode(FTP_RNTO, 100);
	EXPECT_EQ(n, FTP_ERROR);
	n = testFtpCode(FTP_RNTO, 200);
	EXPECT_EQ(n, FTP_OK);
	n = testFtpCode(FTP_RNTO, 300);
	EXPECT_EQ(n, FTP_ERROR);
	n = testFtpCode(FTP_RNTO, 400);
	EXPECT_EQ(n, FTP_FAILED);
	n = testFtpCode(FTP_RNTO, 500);
	EXPECT_EQ(n, FTP_FAILED);
}
TEST(FtpCode, USER_PASS) {
	int n = 0;
	n = testFtpCode(FTP_USER, 100);
	EXPECT_EQ(n, FTP_ERROR);
	n = testFtpCode(FTP_USER, 200);
	EXPECT_EQ(n, FTP_OK);
	n = testFtpCode(FTP_USER, 300);
	EXPECT_EQ(n, FTP_NEXT);
	n = testFtpCode(FTP_USER, 400);
	EXPECT_EQ(n, FTP_FAILED);
	n = testFtpCode(FTP_USER, 500);
	EXPECT_EQ(n, FTP_FAILED);
}
TEST(FtpCode, ACCT) {
	int n = 0;
	n = testFtpCode(FTP_ACCT, 100);
	EXPECT_EQ(n, FTP_ERROR);
	n = testFtpCode(FTP_ACCT, 200);
	EXPECT_EQ(n, FTP_OK);
	n = testFtpCode(FTP_ACCT, 300);
	EXPECT_EQ(n, FTP_ERROR);
	n = testFtpCode(FTP_ACCT, 400);
	EXPECT_EQ(n, FTP_FAILED);
	n = testFtpCode(FTP_ACCT, 500);
	EXPECT_EQ(n, FTP_FAILED);
}

